import {PixelRatio,Dimensions,Platform, NativeModules} from 'react-native';

const { StatusBarManager } = NativeModules;
const dp2px = dp=>PixelRatio.getPixelSizeForLayoutSize(dp);
const px2dp = px=>PixelRatio.roundToNearestPixel(px);
let designSize = {width:750,height:1334}; //假设设计尺寸为：720*1280
let pxRatio = PixelRatio.get();
let win_width = Dimensions.get("window").width;
let win_height = Dimensions.get("window").height;
let width = dp2px(win_width);
let height = dp2px(win_height);
let design_scale = designSize.width/width;
height = height*design_scale;
let scale = 1/pxRatio/design_scale;
let iosHeight = 0;
if(Platform.OS === 'ios'){
        StatusBarManager.getHeight((statusBarHeight)=>{
                iosHeight = statusBarHeight;
        })
}


export default {
        isIOS : Platform.OS === 'ios',
        height,width,
        transform: [{translateX: -width * .5}, {translateY: -height * .5}, {scale: scale}, {translateX: width * .5}, {translateY: height * .5}],
        STATUSBAR_HEIGHT : Platform.OS === 'ios' ? iosHeight : StatusBarManager.HEIGHT,
        scale:scale
}